package com.sentinel.demo.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hh
 * @since 2023/12/16
 */
@RestController
public class TestController {

    @GetMapping("test")
    @SentinelResource(value = "test111",blockHandler = "handleBlock")
    public String test() throws InterruptedException {
        Thread.sleep(4000);
        return "success";
    }

    public String handleBlock(BlockException e) {
        System.out.println("熔断限流");
        return "熔断限流";
    }
}

